sky.use(['dom','ajax','kalendae','flotr2'],function($,ajax){
	$('date').value = new Date().format('YYYY-MM-DD');
	new window.Kalendae.Input('date');

	//查询
	var xSearch = ajax.create('/info?name=turn&history=1','GET').extra({
		oncallback:function(){
			var c = $('progress_list');
			if(this.error){
				c.innerHTML = '<p class="d_error_1">' + this.error + '</p>';
				return ;
			}
			var data = this.responseJSON.data || {};
			var list = i4.backDataSort((data));
			var max = list[1] + 20;
			list = list[0];
			var arr = sky.forEach(list,function(k){
				return [k,data[k]];
			},[]);
			window.Flotr.draw(c, [ arr ], {
				xaxis: {
					tickFormatter:function(num){
						return num + '点';
					},
					minorTickFreq: 4
				},
				yaxis:{
					tickFormatter:function(num){
						return num + '人';
					},
					max:max
				},
				grid: {
					minorVerticalLines: true
				}
			});
		},
		get:function(){
			var pm = {};
			pm.date = $('date').value.replace(/\D+/g,'');
			var from = $('from').value;
			var to = $('to').value;
			if(to < from){
				pm.from = to;
				pm.to = from;
			}
			else{
				pm.from = from;
				pm.to = to;
			}
			this.send(pm,true);
		}
	});

	$.vclick('search_btn',function(){
		xSearch.get();
	});
	xSearch.get();
});